home *** CD-ROM | disk | FTP | other *** search
/ PC Home 49 / PC_Home_Issue_49.iso / lldemo / lldemo.shr / ROSETTA.EXE / ROSETTA.DXR / 00578_dictation scripts.ls < prev    next >
Encoding:
Text File  |  1996-06-24  |  4.7 KB  |  178 lines

  1. on giveDict which
  2.   global gDictMode, gDictNum, gHasPressed
  3.   highlightDictSpeaker(which)
  4.   updateStage()
  5.   set gDictMode to #CLICKPICT
  6.   if which <> gDictNum then
  7.     set gDictNum to 0
  8.   end if
  9.   set gHasPressed to 0
  10.   giveResponse(which)
  11.   set gDictMode to #CLICKSPEAKER
  12. end
  13.  
  14. on handleDictKey
  15.   global gType
  16.   set realKey to " "
  17.   set saveCommand to the commandDown
  18.   set saveShift to the shiftDown
  19.   set saveAlt to the optionDown
  20.   if saveCommand then
  21.     if (the key = "m") and (gType = #MAC) then
  22.       toggleMenu()
  23.     else
  24.       if the key = "q" then
  25.         goQuit()
  26.       else
  27.         if the key = RETURN then
  28.           dontPassEvent()
  29.           checkDictation()
  30.         else
  31.           if (gType = #PC) and (saveAlt = 1) then
  32.             if the key = "<" then
  33.               set realKey to "├ç"
  34.             else
  35.               if (the key = "N") and (saveShift = 1) then
  36.                 set realKey to "├æ"
  37.               else
  38.                 if the key = "," then
  39.                   set realKey to "├º"
  40.                 else
  41.                   if the key = "n" then
  42.                     set realKey to "├▒"
  43.                   else
  44.                     if the key = "s" then
  45.                       set realKey to "├ƒ"
  46.                     else
  47.                       if the key = "1" then
  48.                         set realKey to "┬í"
  49.                       else
  50.                         if the key = "/" then
  51.                           set realKey to "┬┐"
  52.                         else
  53.                           if the key = "]" then
  54.                             set realKey to "┬╗"
  55.                           else
  56.                             if the key = "[" then
  57.                               set realKey to "┬½"
  58.                             end if
  59.                           end if
  60.                         end if
  61.                       end if
  62.                     end if
  63.                   end if
  64.                 end if
  65.               end if
  66.             end if
  67.           end if
  68.         end if
  69.       end if
  70.     end if
  71.   else
  72.     if the key = ENTER then
  73.       dontPassEvent()
  74.       checkDictation()
  75.     else
  76.       if (gType = #PC) and (the key = "6") and (saveShift = 1) then
  77.         dontPassEvent()
  78.       end if
  79.       if (gType = #PC) and ((charToNum(the key) - 65280) = 156) then
  80.         set realKey to numToChar(156)
  81.       end if
  82.     end if
  83.   end if
  84.   if realKey <> " " then
  85.     if the selStart = 0 then
  86.       set beforeText to EMPTY
  87.     else
  88.       set beforeText to char 1 to the selStart of field "dict text"
  89.     end if
  90.     set afterText to char the selEnd + 1 to the number of chars in field "dict text" of field "dict text"
  91.     put beforeText & realKey & afterText into field "dict text"
  92.     set the selStart to the selStart + 1
  93.     set the selEnd to the selStart
  94.   end if
  95. end
  96.  
  97. on checkDictation
  98.   global gDictNum, gPage, gHasPressed
  99.   highlight(33)
  100.   cursor(4)
  101.   updateStage()
  102.   set gHasPressed to 0
  103.   giveResponse(gDictNum)
  104.   set c to the number of cast "chapter text items"
  105.   set c to c + ((gPage - 1) * 4) + gDictNum - 1
  106.   set firstErr to checkStrings(the text of cast 42, the text of cast c)
  107.   if firstErr = 0 then
  108.     alignYesNo(0, #YES)
  109.     giveYeahSnd()
  110.   else
  111.     alignYesNo(0, #no)
  112.     set the selStart to firstErr - 1
  113.     set the selEnd to firstErr
  114.     set the selStart to firstErr - 1
  115.     set the selEnd to firstErr
  116.     giveNoSnd()
  117.   end if
  118.   repeat while soundBusy(1)
  119.   end repeat
  120.   puppetSound(0)
  121.   hideOverlay()
  122.   cursor(-1)
  123.   updateStage()
  124.   unhighlight(33)
  125. end
  126.  
  127. on checkStrings source, correct
  128.   if filter(char 1 of source) = " " then
  129.     set prevChar to " "
  130.     set startNum to 2
  131.   else
  132.     set prevChar to EMPTY
  133.     set startNum to 1
  134.   end if
  135.   set y to 0
  136.   set lenSource to length(source)
  137.   set lenCorrect to length(correct)
  138.   repeat with x = startNum to lenSource
  139.     set theChar to filter(char x of source)
  140.     if not ((theChar = " ") and (prevChar = " ")) then
  141.       set y to y + 1
  142.       set ch to filter(char y of correct)
  143.       repeat while (prevChar = " ") and (ch = " ") and (y <= lenCorrect)
  144.         set y to y + 1
  145.         set ch to filter(char y of correct)
  146.       end repeat
  147.       if y > lenCorrect then
  148.         repeat with ix = x to lenSource
  149.           set theChar to filter(char ix of source)
  150.           if theChar <> " " then
  151.             return x
  152.           end if
  153.         end repeat
  154.         return 0
  155.       else
  156.         if charToNum(theChar) <> charToNum(ch) then
  157.           return x
  158.         end if
  159.       end if
  160.       set prevChar to theChar
  161.     end if
  162.   end repeat
  163.   if y < lenCorrect then
  164.     repeat with iy = y + 1 to lenCorrect
  165.       set ch to filter(char iy of correct)
  166.       if ch <> " " then
  167.         return x
  168.       end if
  169.     end repeat
  170.   end if
  171.   return 0
  172. end
  173.  
  174. on filter ch
  175.   global gFilter
  176.   return char charToNum(ch) of field gFilter
  177. end
  178.